#!/usr/bin/python

"""Tests the functionality of the proc ripple."""

from __future__ import division, print_function

import argparse

from lib import circuit
from lib import ripple

def main():
  parser = argparse.ArgumentParser()
  args = parser.parse_args()

  langdir = circuit.local_lang()
  proc = ripple.Proc(langdir)
  proc.set_spec("/bin/bash",
                ["-c", """echo "'$LANG'" at $MYPROC"""],
                ["LANG=weird LANG val", "MYPROC={}".format(proc.name)])
  proc.start()
  proc.wait()
  print(proc)
  print(proc.spec())
  print("stdout:")
  print(open(proc.stdout_path).read())
  print("stderr:")
  print(open(proc.stderr_path).read())


if __name__ == '__main__':
  main()
